home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / gfx / edit / VE-primcolors.lha / arexx / PrimaryColors.rexx
OS/2 REXX Batch file  |  1999-02-24  |  5KB  |  203 lines

  1. /*
  2.  
  3.    v1.67 PrimaryColors
  4.  
  5.    Marko Seppänen
  6.    marko.seppanen@wwnet.fi
  7.  
  8. */
  9.  
  10. address IMAGEENGINEER
  11.  
  12. Options results
  13. signal on error            /* Setup a place for errors to go */
  14.  
  15. if arg()=0 then exit
  16. x=arg(1)
  17. pic=subword(x,1,1)
  18. check=subword(x,2,1)
  19. randombit=subword(x,3,1)
  20.  
  21.  
  22. MARK pic PRIMARY
  23.  
  24. PROJECT_INFO pic TYPE
  25. info=result
  26. if info~='COLOUR' then do
  27.   CONVERT_TO_COLOUR pic
  28.   x0=RESULT
  29. end
  30. else do
  31.   CONVERT_TO_GREY pic
  32.   tmp=result
  33.   CONVERT_TO_COLOUR tmp
  34.   x0=result
  35.   CLOSE tmp
  36. end
  37.  
  38.  
  39. if randombit="1" then do
  40.  
  41.   x = random(1,12,time('S'))
  42.  
  43.   if x="1" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 0 0'
  44.   if x="2" then 'COLOUR_FILTER' x0 'RGB 255 0 255 0 0 0'
  45.   if x="3" then 'COLOUR_FILTER' x0 'RGB 0 0 255 0 0 0'
  46.   if x="4" then 'COLOUR_FILTER' x0 'RGB 0 0 255 0 255 0'
  47.   if x="5" then 'COLOUR_FILTER' x0 'RGB 0 0 0 0 255 0'
  48.   if x="6" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 255 0'
  49.   if x="7" then 'COLOUR_FILTER' x0 'RGB 40 0 100 0 255 0'
  50.   if x="8" then 'COLOUR_FILTER' x0 'RGB 40 0 100 0 0 0'
  51.   if x="9" then 'COLOUR_FILTER' x0 'RGB 255 0 125 0 0 0'
  52.   if x="10" then 'COLOUR_FILTER' x0 'RGB 100 0 0 0 0 0'
  53.   if x="11" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 -128 0'
  54.   if x="12" then 'COLOUR_FILTER' x0 'RGB 255 0 200 0 255 0'
  55.  
  56.   CLOSE x0
  57.  
  58.   exit
  59.  
  60. end
  61.  
  62.  
  63.  
  64.  
  65. if exists("ie:prefs/veprimarycolors.cfg") == "1" then
  66.   do
  67.     call open("temp","ie:prefs/veprimarycolors.cfg","R")
  68.     values=readln("temp")
  69.     parse var values ok color contr all .
  70.     call close("temp")
  71.   end
  72. else
  73.   do
  74.     color=0
  75.     contr=1
  76.     all=0
  77.   end
  78.  
  79.  
  80. if check~="1" then do
  81.  
  82.   'FORM "Primary Colors" "Use|Cancel"',
  83.   'CYCLE,"Choose color","DRed|Yellow|Green|LBlue|DBlue|Violet|Blue|DGreen|Brown|Red|Orange|Pink",'color'',
  84.   'CHECKBOX,"Contrast stretch",'contr'',
  85.   'CHECKBOX,"All 12 colors",'all''
  86.  
  87.   values=result
  88.   parse var values ok color contr all .
  89.  
  90. end
  91. else do
  92.  
  93.     all=0
  94.  
  95. end
  96.  
  97.  
  98. if ok = 0 then exit
  99.  
  100. call open("temp","ie:prefs/veprimarycolors.cfg","W")
  101. res=writeln("temp",values)
  102. call close("temp")
  103.  
  104.  
  105. if all == "1" then do
  106.   'COLOUR_FILTER' x0 'RGB 255 0 0 0 0 0'
  107.   if contr="1" then Call Contr result
  108.   'COLOUR_FILTER' x0 'RGB 255 0 255 0 0 0'
  109.   if contr="1" then Call Contr result
  110.   'COLOUR_FILTER' x0 'RGB 0 0 255 0 0 0'
  111.   if contr="1" then Call Contr result
  112.   'COLOUR_FILTER' x0 'RGB 0 0 255 0 255 0'
  113.   if contr="1" then Call Contr result
  114.   'COLOUR_FILTER' x0 'RGB 0 0 0 0 255 0'
  115.   if contr="1" then Call Contr result
  116.   'COLOUR_FILTER' x0 'RGB 255 0 0 0 255 0'
  117.   if contr="1" then Call Contr result
  118.   'COLOUR_FILTER' x0 'RGB 40 0 100 0 255 0'
  119.   if contr="1" then Call Contr result
  120.   'COLOUR_FILTER' x0 'RGB 40 0 100 0 0 0'
  121.   if contr="1" then Call Contr result
  122.   'COLOUR_FILTER' x0 'RGB 255 0 125 0 0 0'
  123.   if contr="1" then Call Contr result
  124.   'COLOUR_FILTER' x0 'RGB 100 0 0 0 0 0'
  125.   if contr="1" then Call Contr result
  126.   'COLOUR_FILTER' x0 'RGB 255 0 0 0 -128 0'
  127.   if contr="1" then Call Contr result
  128.   'COLOUR_FILTER' x0 'RGB 255 0 200 0 255 0'
  129.   if contr="1" then Call Contr result
  130.  
  131.   CLOSE x0
  132.   exit
  133.  
  134. end
  135. else do
  136.  
  137.   if color == "0" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 0 0'
  138.   if color == "1" then 'COLOUR_FILTER' x0 'RGB 255 0 255 0 0 0'
  139.   if color == "2" then 'COLOUR_FILTER' x0 'RGB 0 0 255 0 0 0'
  140.   if color == "3" then 'COLOUR_FILTER' x0 'RGB 0 0 255 0 255 0'
  141.   if color == "4" then 'COLOUR_FILTER' x0 'RGB 0 0 0 0 255 0'
  142.   if color == "5" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 255 0'
  143.   if color == "6" then 'COLOUR_FILTER' x0 'RGB 40 0 100 0 255 0'
  144.   if color == "7" then 'COLOUR_FILTER' x0 'RGB 40 0 100 0 0 0'
  145.   if color == "8" then 'COLOUR_FILTER' x0 'RGB 255 0 125 0 0 0'
  146.   if color == "9" then 'COLOUR_FILTER' x0 'RGB 100 0 0 0 0 0'
  147.   if color == "10" then 'COLOUR_FILTER' x0 'RGB 255 0 0 0 -128 0'
  148.   if color == "11" then 'COLOUR_FILTER' x0 'RGB 255 0 200 0 255 0'
  149.  
  150.   col=result
  151.  
  152. end
  153.  
  154. if check~="1" then do
  155.   if contr="1" then CALL Contr col
  156. end
  157.  
  158. CLOSE x0
  159.  
  160.  
  161. exit
  162.  
  163. end
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170. Contr:
  171.  
  172.   x1=arg(1)
  173.  
  174.   CONTRAST_STRETCH x1
  175.   x2=result
  176.   CLOSE x1
  177.  
  178.   CONTRAST x2 20
  179.   CLOSE x2
  180.  
  181. Return
  182.  
  183.  
  184. exit
  185.  
  186. /*******************************************************************/
  187. /* This is where control goes when an error code is returned by IE */
  188. /* It puts up a message saying what happened and on which line     */
  189. /*******************************************************************/
  190. error:
  191. if RC=5 then do            /* Did the user just cancel us? */
  192.     IE_TO_FRONT
  193.     LAST_ERROR
  194.     'REQUEST "'||RESULT||'"'
  195.     exit
  196. end
  197. else do
  198.     IE_TO_FRONT
  199.     LAST_ERROR
  200.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  201.     exit
  202. end
  203.